Optional Fontrast-to-fnt.f
\ OUTPUT FORMAT (.FNT)
\ header: mincode maxcode
\   chars: subimage, subimage ...  ( x y w h xofs yofs xstride char )
Requires Tools
Requires Kagi

Only Forth Definitions

: char^
   over - locals| xstride xofs h w y x page code |
   x h^ y h^ w h^ h h^ xofs h^ 0 h^ xstride h^ code h^ ;

-? 0 value #1
: convert-fontrast ( -- <file.txt> )
   0 parse pad place
   pad count file:[ nip to #1
      pad count -ext pad place s" .fnt" pad append

      pad count file-out:[

         #1 get-line 3drop \ FONTRAST
         #1 get-line 3drop \ version

         \ NumChars, NumPages, MinCode, MaxCode and CellHeight
         #1 get-line drop evaluate drop swap h^ h^ 2drop

         \ Characters
         begin #1 get-line over 3 > and while
             tabs>spaces evaluate
             char^
         repeat 2drop
      ;]
   ;] cr ." Success" ;
